variable CCSRBAR 0xFE000000

proc CCSR_ADDR {reg_off} {
	global CCSRBAR

	return i:0x[format %x [expr {$CCSRBAR + $reg_off}]]
}

proc init_board {} {
	# Disable Boot Space Translation
	mem [CCSR_ADDR 0x28] = 0x00000000
	# Initialize CPC1
	mem [CCSR_ADDR 0x10000] = 0x00200400
	# Configure CPC1 as 256KB SRAM
	mem [CCSR_ADDR 0x10100] = 0x00000000
	mem [CCSR_ADDR 0x10104] = 0xFFFC0007
	mem [CCSR_ADDR 0x10F00] = 0x081E000D
	mem [CCSR_ADDR 0x10000] = 0x80000000
	# Configure LAW for CPC1
	mem [CCSR_ADDR 0xCD0] = 0x00000000
	mem [CCSR_ADDR 0xCD4] = 0xFFFC0000
	mem [CCSR_ADDR 0xCD8] = 0x81000011
}

proc T1040RDB_init_core {} {
	init_board
}

proc envsetup {} {
	# Environment Setup
	radix x
	config hexprefix 0x
	config MemIdentifier v
	config MemWidth 32
	config MemAccess 32
	config MemSwap off
}

# -------------------------------------------------------------------------------
# Main
# -------------------------------------------------------------------------------

envsetup

config runcontrolsync on

T1040RDB_init_core
